package com.zz.service.impl;

import com.zz.entity.Book;
import com.zz.form.BookForm;
import com.zz.repository.BookRepository;
import com.zz.service.BookService;
import com.zz.util.KeyUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: java类作用描述
 * @Author: Bsea
 * @CreateDate: 2019/5/22$ 20:49$
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookRepository bookRepository;
    @Override
    public Book add(BookForm bookForm) {

        Book book =new Book();
        BeanUtils.copyProperties(bookForm,book);
        book.setId(KeyUtil.genUniqueLongKey());
        return bookRepository.save(book);
    }

    @Override
    public List<Book> findByOpenid(String openid) {
        return bookRepository.findByOpenid(openid);
    }
}
